package com.ouyy.volunteerservice.volunteer.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ouyy.volunteerservice.volunteer.domain.po.VolunteerActivities;
import com.ouyy.volunteerservice.volunteer.mapper.VolunteerActivateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class VolunteerActivateService  extends ServiceImpl<VolunteerActivateMapper, VolunteerActivities> {
    @Autowired
    private VolunteerActivateMapper activitiesMapper;
    public VolunteerActivities getVolunteerActivityById(Long id) {
        return getById(id);
    }

    public boolean updateActivity(VolunteerActivities activity) {
        // 执行更新操作，这里假设使用Mapper更新数据库
        int updatedRows = activitiesMapper.updateById(activity);

        // 根据更新的行数判断更新是否成功
        return updatedRows > 0;
    }

    // 按活动类别统计活动数量
    public List<Map<String, Object>> countActivitiesByCategory() {
        return activitiesMapper.countActivitiesByCategory();
    }

    public List<Map<String, Object>> countActivitiesByMonth() {
        return activitiesMapper.countActivitiesByMonth();
    }

    public List<VolunteerActivities> getAllData() {
        return this.list();  // MyBatis-Plus 的 list() 方法，查询所有数据
    }
}
